package com.lili.goods.controller;

import com.lili.common.result.Result;
import com.lili.goods.service.GoodsSpecValuesService;
import com.lili.goods.service.GoodsSpecificationService;
import com.lili.model.goods.GoodsSpecValues;
import com.lili.model.goods.GoodsSpecification;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
@Api(tags = "商品规格")
public class GoodsSpecificationController {
    @Autowired
    GoodsSpecificationService goodsSpecificationService;

    @ApiOperation("商品规格查询")
    @GetMapping("/specification")
    public Result getGoodsSpecValues() {
        List<GoodsSpecification> list = goodsSpecificationService.getSpecification();
        return Result.ok(list);
    }

    @ApiOperation("商品规格保存")
    @PostMapping("/specification")
    public Result saveGoodsSpecValues(@RequestBody GoodsSpecification goodsSpecification) {
        int i = goodsSpecificationService.saveSpecification(goodsSpecification);
        return Result.ok("保存成功" + i);
    }

    @ApiOperation("商品规格更新")
    @PutMapping("/specification")
    public Result updateGoodsSpecValues(@RequestBody GoodsSpecification goodsSpecification) {
        int i = goodsSpecificationService.updateSpecification(goodsSpecification);
        return Result.ok("更新成功" + i);
    }

    @ApiOperation("商品规格删除")
    @DeleteMapping("/specification")
    public Result deleteGoodsSpecValues(@RequestBody GoodsSpecification goodsSpecification) {
        int i = goodsSpecificationService.deleteSpecification(goodsSpecification);
        return Result.ok("删除成功" + i);
    }


}
